//
//  BCProjectDetailDataView.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/22.
//  Copyright © 2018年 guoshikeji. All rights reserved.
//

#import "BCProjectDetailDataView.h"

@interface BCProjectDetailDataView ()

@property (nonatomic, strong) CAShapeLayer *lineLayer;

@end

@implementation BCProjectDetailDataView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setupSubviews];
    }
    return self;
}
- (void)setupSubviews {
    self.lineLayer = [CAShapeLayer layer];
    self.lineLayer.lineWidth = .3;
    self.lineLayer.strokeColor = [UIColor colorWithWhite:1 alpha:.3].CGColor;
    self.lineLayer.fillColor = [UIColor clearColor].CGColor;
    [self.layer addSublayer:self.lineLayer];
    //
    self.goalView = [HomeCellDataView new];
    self.goalView.titleLabel.textColor = self.goalView.dataLabel.textColor = [UIColor whiteColor];
    [self addSubview:self.goalView];
    [self.goalView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self);
        make.centerY.mas_equalTo(self);
        make.height.mas_equalTo([HomeCellDataView defaultHeight]);
        make.right.mas_equalTo(self.mas_centerX);
    }];
    //
    self.rateView = [HomeCellDataView new];
    self.rateView.titleLabel.textColor = self.rateView.dataLabel.textColor = [UIColor whiteColor];
    [self addSubview:self.rateView];
    [self.rateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self);
        make.centerY.mas_equalTo(self);
        make.height.mas_equalTo([HomeCellDataView defaultHeight]);
        make.left.mas_equalTo(self.mas_centerX).offset(33.0);
    }];
}


- (void)layoutSubviews {
    [super layoutSubviews];
    //
    [self setLines];
}

- (void)setLines {
    //6根线
    NSInteger lines = 6;
    CGFloat width = self.frame.size.width;
    CGFloat height = self.frame.size.height;
    UIBezierPath *bPath = [UIBezierPath bezierPath];
    CGFloat padding = height/(lines-1);
    for (int i=0; i<lines; i++) {
        CGFloat y = i*padding;
        [bPath moveToPoint:CGPointMake(0, y)];
        [bPath addLineToPoint:CGPointMake(width, y)];
    }
    self.lineLayer.path = bPath.CGPath;
}


+ (CGFloat)defaultHeight {
    return 55.0;
}

@end
